package org.liang.auth.controller;

import org.liang.auth.dto.LoginDTO;
import org.liang.auth.service.ILoginService;
import org.liang.base.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private ILoginService loginService;

    /**
     * 登录
     * @return
     */
    @PostMapping
    public AjaxResult login(@RequestBody LoginDTO loginDTO){
        try {
            Map<String,Object> map = loginService.login(loginDTO);
            return AjaxResult.success(map);
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.error(e.getMessage());
        }
    }
}
